import md5 from 'js-md5' 
export default {
    // 金额格式化千分位
    formatAmt(value) {
        if (value) {
            const val = value.toString().replace(/,/g, '')
            return Number(val).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
        } else {
            return '0.00'
        }
    },
	
	// tabs过渡
	goAnchor(selector) {
		document.getElementById(selector).scrollIntoView({
			behavior: "smooth", // 平滑过渡
			block: "center", // 上边框与视窗顶部平齐。默认值
			inline:'nearest'
		});
	},
	
	
	pwdEncode(pwd, um, randomCode) {
	  for (let i = 0; i < 3; i++) {
	    if (i != 0) {
	      pwd = pwd.toLowerCase()
	    }
	    pwd = md5(pwd)
	  }
	
	  for (let i = 0; i < 4; i++) {
	    pwd = pwd.toLowerCase()
	
	    if (i == 0) {
	      pwd = um + pwd
	    }
	    pwd = md5(pwd)
	  }
	  pwd = pwd.toLowerCase() + randomCode
	  pwd = md5(pwd).toLowerCase()
	  return pwd
	},
}
